package com.dgshanger.sanhxiaofeisc.mvp.model

import com.dgshanger.sanhxiaofeisc.common.AppApi
import com.dgshanger.sanhxiaofeisc.entity.CheckPwdEntity
import com.dgshanger.sanhxiaofeisc.entity.LoosePaymentEntity
import com.dgshanger.sanhxiaofeisc.entity.PaymentCodeEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.PaymentCodeContract
import com.xx.baseutilslibrary.network.rx.RxHelper
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/20.
 */
class PaymentCodeModel : PaymentCodeContract.Model {

    override fun checkPayPwd(httpObserver: XxBaseHttpObserver<CheckPwdEntity>?) {
        AppApi.Api().checkPwd()
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }

    override fun goPay(shop_id: String?, pay_amount: String?, pay_type: String?, user_pay_pwd: String?, user_wallet_amount: String?, user_integral_amount: String?, httpObserver: XxBaseHttpObserver<LoosePaymentEntity>?) {
        AppApi.Api().shopLoosePayment(shop_id,pay_amount,pay_type,user_pay_pwd,user_wallet_amount,user_integral_amount)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }

    override fun loadData(shop_number: String?, httpObserver: XxBaseHttpObserver<PaymentCodeEntity>?) {
        AppApi.Api().getScanCodeData(shop_number)
                .compose(RxHelper.io_main())
                .compose(RxHelper.start_finish(httpObserver))
                .subscribe(httpObserver)
    }


}